﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Lab1.Classes
{
    public class SyncObject
    {
        public string Name { get; protected set; }
        public IEngine Engine { get; protected set; }
        public int LocalTimeStamp { get; set; }
        public List<SyncQueue> Queues { get; protected set; }

        public SyncObject(IEngine engine)
        {
            Engine = engine;
            Queues = new List<SyncQueue>();
            LocalTimeStamp = 0;
        }

        public SyncQueue GetMessageByReceiver(SyncObject receiver)
        {
            return Queues.First(q => q.Receiver == receiver);
        }

        public virtual void SendMessage(Message message)
        {
            throw new NotImplementedException();
        }

        public virtual void ReceiveMessage(Message message)
        {
            throw new NotImplementedException();
        }

        protected virtual void ProgressTime()
        {
            throw new NotImplementedException();
        }

        public void ThreadContainerMethod()
        {
            Console.WriteLine("{0}: начало, t = {1}", Name, LocalTimeStamp);
            ProgressTime();
            Console.WriteLine("{0}: конец, t = {1}", Name, LocalTimeStamp);
        }
    }
}